<?php
 
 
$socket = stream_socket_client('tcp://127.0.0.1:502', $errno, $errstr);

if(!$socket)
{
	die($errno.$errstr);
}

else
{
	while(1) {
		
		// stream_set_blocking($socket, 0);
		fwrite($socket,"00 0D 00 00 00 06 01 03 00 00 00 0A");
		
		$response = fread($socket, 1024);
			
		file_put_contents('log.txt', date("[H:i:s] ", time()).$response."\n", FILE_APPEND);
		
		
	}
	
	fclose($socket);
}

 
?>
